#include <REGX52.H>
#include "uart.c"
#include "game.h"
#include "display.c"
/**
 * 实现左右按键，通过左右按键实现数字的切换。
 * 0~9, 9+ = 0  0-=9
 */
sbit BTN_LEFT = P1 ^ 4;
sbit BTN_RIGHT = P1 ^ 5;

unsigned int num = 0;

void main()
{
    uart_init();
    display_init();
    display_speed_select_screen();
    display_speed_select_num(num);
    while (1)
    {

        if (BTN_LEFT == 0)
        {
            delay(20);
            if (BTN_LEFT == 0)
            {

                if (num == 9)

                    num = 0;

                else

                    num++;

                display_speed_select_num(num);

                while (BTN_LEFT == 0)
                    delay(20);
            }
        }
        if (BTN_RIGHT == 0)
        {
            delay(20);
            if (BTN_RIGHT == 0)
            {
                if (num == 0)

                    num = 9;

                else

                    num--;

                display_speed_select_num(num);

                while (BTN_RIGHT == 0)
                    delay(20);
            }
        }
    }
}